﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace SCCL2010
{
    public static class Folders
    {
        public static bool HasFolder(SPFolder oFolder, string cFolderName)
        {
            try
            {
                foreach (SPFolder childfolder in oFolder.SubFolders)
                {
                    if (childfolder.Name.ToLower() == cFolderName.ToLower())
                        return true;
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.HandleError(oFolder.ParentWeb, "Folders.HasFolder", ex);
            }
            return false;
        }

        public static SPFolder GetFolder(SPFolder oFolder, string cFolderName)
        {
            try
            {
                foreach (SPFolder childfolder in oFolder.SubFolders)
                {
                    if (childfolder.Name.ToLower() == cFolderName.ToLower())
                        return childfolder;
                }
            }
            catch (Exception ex)
            {
                ErrorHandling.HandleError(oFolder.ParentWeb, "Folders.GetFolder", ex);
            }
            return null;
        }
    }
}
